from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class editor_logic_fake :
    def __init__ ( self ) :
        self . _show_editor = False
        self . _hide_editor = False
        self . _select_knowledge_base_for_editing = [ ]
        self . _save_knowledge_base_in_editor = False
        self . _save_as_knowledge_base_in_editor = None
        self . _on_key_escape = False
        self . _key_escape_counter_reply = None
    def show_editor ( self ) :
        self . _show_editor = True
    def hide_editor ( self ) :
        self . _hide_editor = True
    def select_knowledge_base_for_editing ( self , base_name ) :
        self . _select_knowledge_base_for_editing += [ base_name ]
    def save_knowledge_base_in_editor ( self ) :
        self . _save_knowledge_base_in_editor = True
    def save_as_knowledge_base_in_editor ( self , base_name ) :
        self . _save_as_knowledge_base_in_editor = base_name
    def on_key_escape ( self ) :
        self . _on_key_escape = True
    def key_escape_counter_reply ( self , counter ) :
        self . _key_escape_counter_reply = counter

class arbitrary_module_fake :
    def show_editor ( self ) :
        pass
    def hide_editor ( self ) :
        pass
    def on_key_escape ( self ) :
        pass
    def key_escape_counter_reply ( self , counter ) :
        pass

class mediator_editor_logic_tests : 
    'mediator_editor_logic'
    def __init__ ( self , test ) :
        self . _test = test
        self . _editor_logic = editor_logic_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'editor_logic' 
            , self . _editor_logic 
            , arbitrary_module_fake
            ) )
    def test_show_editor ( self ) :
        self . _mediator . show_editor ( )
        self . _test . assume_true ( self . _editor_logic . _show_editor )
    def test_hide_editor ( self ) :
        self . _mediator . hide_editor ( )
        self . _test . assume_true ( self . _editor_logic . _hide_editor )
    def test_select_knowledge_base_for_editing ( self ) :
        self . _mediator . select_knowledge_base_for_editing ( 'my base' )
        self . _test . assume_equal ( self . _editor_logic . _select_knowledge_base_for_editing , [ 'my base' ] )
    def test_save_knowledge_base_in_editor ( self ) :
        self . _mediator . save_knowledge_base_in_editor ( )
        self . _test . assume_true ( self . _editor_logic . _save_knowledge_base_in_editor )
    def test_save_as_knowledge_base_in_editor ( self ) :
        self . _mediator . save_as_knowledge_base_in_editor ( 'my name' )
        self . _test . assume_equal ( self . _editor_logic . _save_as_knowledge_base_in_editor , 'my name' )
    def test_on_key_escape ( self ) :
        self . _mediator . on_key_escape ( )
        self . _test . assume_true ( self . _editor_logic . _on_key_escape )
    def test_key_escape_counter_reply ( self ) :
        self . _mediator . key_escape_counter_reply ( 'my counter' )
        self . _test . assume_equal ( self . _editor_logic . _key_escape_counter_reply , 'my counter' )
